﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MudEngine.Parsing.AST
{
	public class CastExpression : Expression
	{
		public Expression Expression { get; private set; }

		public CastExpression(AType type, Expression expression)
		{
			this.Type = type;
			this.Expression = expression;
		}

		public CheckExpressionResult CheckExpressions()
		{
			if (!CompatibleTypes(COMPATIBLES_COMPARE, this.Type.SystemType, this.Expression.Type.SystemType))
				return CheckExpressionResult.RIGHT | CheckExpressionResult.LEFT;

			return CheckExpressionResult.OK;
		}

		public override void AcceptVisitor<C>(IAstNodeVisitor<C> visitor, C ctx)
		{
			visitor.VisitCastExpression(this, ctx);
		}
	}
}
